Skip to content

fix(gpkg): merge GPKG sources lowest zoom first again - #277

Merged
shimoncohen merged 4 commits into
masterfrom
fix/gpkg-batch-order
Nov 25, 2026
Merged

shimoncohen merged 4 commits into
masterfrom
fix/gpkg-batch-order

Conversation

@shimoncohen

Copy link
Copy Markdown
Collaborator
Question Answer
Bug fix ✔
New feature ✖
Breaking change ✖
Deprecations ✖
Documentation ✖
Tests added ✔
Chore ✖

Related issues: #255
Closes #276

Further information:

Since #255, GPKG sources are paged by rowid, so a table that isn't stored lowest zoom first is merged in a different order than in v2.2.3, and partial tiles get filled from a different lower zoom.

Tests: all unit tests pass (1,128 MergerLogic, 23 MergerService). A z16+z18 merge into a GPKG and into an FS tree is byte-identical to v2.2.3 on all 34,764 tiles; on master 897 tiles differ.

Touches GpkgClient.cs like #274, in a different method; the two merge without conflict.

Keyset paging moved GetBatch from `ORDER BY zoom_level LIMIT/OFFSET` to
`WHERE rowid > $lastId ORDER BY rowid`. Rowid order is insertion order, so
tables not stored lowest zoom first are now merged in a different order.
That changes output: a partial tile is filled by upscaling the closest
lower zoom already in the target. On a z16+z18 merge whose source stores
z18 rows first, 897 of 34,764 tiles differed from v2.2.3.

Page on the GPKG's UNIQUE(zoom_level, tile_column, tile_row) index instead:
`WHERE (zoom_level, tile_column, tile_row) > (z, x, y)`. That is the order
v2.2.3's query used (it scanned the same index), and the seek keeps the
constant page cost. GPKG and FS outputs of that merge are now
byte-identical to v2.2.3.

The cursor is the last tile's coordinates; the resume batch identifier
becomes "z/x/y" ("0" before the first batch), and anything else is
rejected instead of silently restarting.

Closes #276
shimoncohen and others added 3 commits November 25, 2026 13:35
…cursor

The journal-mode tests merged from master still passed an int offset to GetBatch, which now takes a tile cursor, so the test project no longer compiled.
@shimoncohen
shimoncohen merged commit 7d80fac into master Nov 25, 2026
3 checks passed
@shimoncohen
shimoncohen deleted the fix/gpkg-batch-order branch November 25, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GPKG sources are merged in rowid order instead of lowest zoom first

2 participants